package com.caucho.hessian.callback;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

public class HessianCallback  implements Serializable{
	private static final long serialVersionUID = 8687035754542038840L;
	
	private String callbackUrl;
	private Map<String,String> params=new HashMap<String,String>();
	
	public String getCallbackUrl() {
		return callbackUrl;
	}
	public void setCallbackUrl(String callbackUrl) {
		this.callbackUrl = callbackUrl;
	}
	public void addAttribute(String key,String value) {
		params.put(key, value);
	}
	public Object getAttribute(String key){
		return params.get(key);
	}
	public void removeAttribute(String key){
		params.remove(key);
	}
	
	public Map<String, String> getMap() {
		return params;
	}
	public void setMap(Map<String, String> map) {
		this.params = map;
	}
	
	public HessianCallback clone(){
		HessianCallback hc=new HessianCallback();
		hc.setCallbackUrl(this.callbackUrl);
		hc.getMap().putAll(this.params);
		return hc;
	}
	
	public String toString(){
		StringBuffer sb=new StringBuffer();
		sb.append(callbackUrl);
		for(String key:params.keySet()){
			sb.append(key+":"+params.get(key));
		}
		return sb.toString();
	}
	
	
}
